package org.ydsw.data.manage.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.ydsw.data.manage.entity.User;
import org.ydsw.data.manage.mapper.UserMapper;
import org.ydsw.data.manage.service.UserService;
import org.ydsw.data.manage.utils.AESUtil;

import java.util.List;

@Service("userService")
public class UserServiceimpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    }

    @Override
    public int getUserCount(String username) {
        return userMapper.getUserNameCount(username);
    }


    @Override
    public String getPassword(String username) {
        return userMapper.getPassword(username);
    }

    //验证密码方法
    public Boolean isPass(String username, String password) {
        String truePassword = getPassword(username);
        String decodePassword = AESUtil.decode(truePassword);
        if (password.equals(decodePassword))
            return true;
        else return false;
    }
}
